import request from '@/utils/request'

// 查询产品列表
export function listBizProduct (query) {
  return request({
    url: '/biz/bizProduct/list',
    method: 'get',
    params: query
  })
}

export function listBizProduct4Bom (query) {
  return request({
    url: '/biz/bizProduct/list4Bom',
    method: 'get',
    params: query
  })
}

// 查询产品详细
export function getBizProduct (id) {
  return request({
    url: '/biz/bizProduct/' + id,
    method: 'get'
  })
}

// 新增产品
export function addBizProduct (data) {
  return request({
    url: '/biz/bizProduct',
    method: 'post',
    data: data
  })
}

// 修改产品
export function updateBizProduct (data) {
  return request({
    url: '/biz/bizProduct',
    method: 'put',
    data: data
  })
}

// 删除产品
export function delBizProduct (id) {
  return request({
    url: '/biz/bizProduct/' + id,
    method: 'delete'
  })
}


// 导出产品
export function exportBizProduct (query) {
  return request({
    url: '/biz/bizProduct/export',
    method: 'get',
    params: query
  })
}

// 获取初始化数据
export function getInitData (dictTypes) {
  return request({
    url: '/biz/bizProduct/getInitData/' + dictTypes,
    method: 'get'
  })
}
// 获取初始化数据
export function importData (params) {
  return request({
    url: '/biz/bizProduct/importData',
    method: 'post',
    params:params
  })
}
// 校验信息重复
export function checkDataUnique (params) {
  return request({
    url: '/biz/bizProduct/checkDataUnique',
    method: 'get',
    params:params
  })
}

// 查询产品树结构
export function listTree (id, expandLevel) {
  if (id == null || id === '') {
    id = '0'
  }
  if (expandLevel == null || expandLevel === '') {
    expandLevel = '1'
  }
  return request({
    url: '/biz/bizProduct/listTree/' + expandLevel + '/' + id,
    method: 'get'
  })
}